phi: avoid intermediate overflow in BE scale#241
Merged
ChrisRackauckas merged 1 commit intoJul 8, 2026
Conversation
Compute the backward-error scaling factor in log space so large p or small normalized norms cannot underflow/overflow before the final root is taken. Add BigFloat-referenced regression coverage for the problematic scale regimes Steven flagged. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ignore until reviewed by @ChrisRackauckas.
Follow-up to #236 / Steven's numerical-stability comment.
Summary
exp((logcoeff - delta*log(normTs))/K)instead of(_phi_be_coeff(m, p) / normTs^delta)^(1/K).Inf,NaN, or zero intermediates for largep/ tiny normalized norms when the final rooted scale is representable.normTs = 1e-8, 1e-2, 0.5, 1.0, 1.9;p = 60, 200, 500).Local verification
timeout 3600 /home/crackauc/.juliaup/bin/julia +1.10 --project=. -e 'using Pkg; Pkg.test()'Core/basictests.jl | 673 pass, 1 broken, 674 totaltimeout 3600 /home/crackauc/.juliaup/bin/julia +1.10 -e 'using Pkg; Pkg.activate(; temp=true); Pkg.add("Runic"); using Runic; exit(Runic.main(["--check", "."]))'timeout 3600 /home/crackauc/.juliaup/bin/julia +1.10 --project=test/qa -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate(); include("test/qa/qa.jl")'Quality Assurance | 15 pass, 1 broken, 16 totalExtra stress checks
Ran a separate local harness against scalar-series / legacy / block-exponential references for:
p = 80: worst relerr2.78e-17p = 60: worst relerr2.22e-16p = 8: worst relerr6.32e-16p = 6: worst relerr3.34e-14p = 10: worst relerr6.66e-16p = 6: worst relerr2.68e-15pcall returnedcache.info == 0and finite outputs.